package edu.calvin.djs32.cs214.interpreters.drivers;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.RecognitionException;

import edu.calvin.cs214.hobbes2008.HobbesTIR;
import edu.calvin.djs32.cs214.interpreters.calculator.Calculator;
import edu.calvin.djs32.cs214.interpreters.frontend.Hobbes2008FrontEnd;

public class PrettyPrintedCalculatorCLIDriver {
	private static void generateOutput(Calculator calculator, HobbesTIR process) throws IOException, RecognitionException {
		PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter("CalcOutput.html")));
		output.println("<html>");
		output.println("<head>");
		output.println("<style type=text/css>");
		output.println(".integer  {color: blue}");
		output.println(".negative  {color: red}");
		output.println(".string  {color: green}");
		output.println("</style>");
		output.println("</head>");
		output.println("<body>");
		output.println(process.accept(calculator));
		output.println("</body>");
		output.println("</html>");
		output.close();
	}
	
	public static void main(String[] args) throws RecognitionException, IOException{
		HobbesTIR process = new Hobbes2008FrontEnd().process(new ANTLRFileStream("calc.hob"));
		Calculator myCalculator = new Calculator();			
		generateOutput(myCalculator, process);
	}

}
